package route

import (
	"gq_volunteer_platform/controller"
	"gq_volunteer_platform/controller/activity"
	"gq_volunteer_platform/controller/admin"
	"gq_volunteer_platform/controller/config"
	"gq_volunteer_platform/controller/help_request"
	"gq_volunteer_platform/controller/index"
	"gq_volunteer_platform/controller/material"
	"gq_volunteer_platform/controller/news"
	"gq_volunteer_platform/controller/organization"
	"gq_volunteer_platform/controller/point_application"
	"gq_volunteer_platform/controller/upload"
	"gq_volunteer_platform/controller/user"
	"gq_volunteer_platform/middleware"

	"github.com/gin-gonic/gin"
)

func Admin(router *gin.Engine) {

	// router.Static("/upload", "upload") // 服务静态文件 相对路径为 项目启动时 用户所在目录

	router.GET("test", controller.Test)
	router.GET("test2", controller.Test2)
	router.GET("time", controller.Time)
	router.POST("AddDep", controller.AddDep)
	router.GET("/admin/CaptchaId", admin.CaptchaId)
	router.GET("/admin/Captcha", admin.Captcha)
	router.POST("/admin/Login", admin.Login)

	router.GET("/admin/LoginQrCodeTicket", admin.LoginQrCodeTicket)
	router.GET("/admin/LoginQrCode", admin.LoginQrCode)
	router.GET("/admin/CheckQrCodeLogin", admin.CheckQrCodeLogin)

	// 文件上传接口
	router.POST("/upload/Upload", middleware.Record, middleware.Login, middleware.Permission, upload.Upload)

	// admin
	adminGroup := router.Group("admin")
	adminGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		adminGroup.GET("test", admin.Test)
		adminGroup.GET("MyList", admin.MyList)
		adminGroup.POST("Edit", admin.Edit)
		adminGroup.POST("Delete", admin.Delete)

		adminGroup.GET("Info", admin.Info)
		adminGroup.POST("Logout", admin.Logout)
		adminGroup.POST("ChangePassword", admin.ChangePassword)
		adminGroup.GET("BindWeixinQrCode", admin.BindWeixinQrCode)

		adminGroup.GET("RecordList", admin.RecordList)

		adminGroup.GET("RoleAllList", admin.RoleAllList)
		adminGroup.GET("RoleList", admin.RoleList)
		adminGroup.GET("RoleDetail", admin.RoleDetail)
		adminGroup.POST("RoleEdit", admin.RoleEdit)
		adminGroup.POST("RoleDelete", admin.RoleDelete)
		adminGroup.POST("RolePermissionEdit", admin.RolePermissionEdit)

		adminGroup.GET("MenuTree", admin.MenuTree)
		adminGroup.GET("MenuDetail", admin.MenuDetail)
		adminGroup.POST("MenuEdit", admin.MenuEdit)
		adminGroup.POST("MenuDelete", admin.MenuDelete)
	}

	// user
	userGroup := router.Group("user")
	userGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		userGroup.GET("List", user.List)
		userGroup.GET("MyList", user.MyList)
		userGroup.GET("Detail", user.Detail)
		userGroup.POST("Check", user.Check)
		userGroup.POST("ExitOrganization", user.ExitOrganization)
		userGroup.POST("ReducePoint", user.ReducePoint)
		userGroup.GET("PointRecordList", user.PointRecordList)

		userGroup.GET("MyChangeList", user.MyChangeList)
		userGroup.POST("ChangeOrganizationCheck", user.ChangeOrganizationCheck)

		userGroup.GET("ExistList", user.ExistList)
		userGroup.POST("ExistCheck", user.ExistCheck)
	}

	// config
	configGroup := router.Group("config")
	configGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		configGroup.GET("Detail", config.Detail)
		configGroup.POST("Edit", config.Edit)
	}

	// news
	newsGroup := router.Group("news")
	newsGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		newsGroup.GET("MyList", news.MyList)
		newsGroup.GET("List", news.List)
		newsGroup.POST("Edit", news.Edit)
		newsGroup.GET("Detail", news.Detail)
		newsGroup.POST("Delete", news.Delete)
		newsGroup.POST("Check", news.Check)
		newsGroup.POST("Top", news.Top)

		newsGroup.GET("CategoryAllList", news.CategoryAllList)
		newsGroup.GET("CategoryList", news.CategoryList)
		newsGroup.POST("CategoryEdit", news.CategoryEdit)
		newsGroup.GET("CategoryDetail", news.CategoryDetail)
		newsGroup.POST("CategoryDelete", news.CategoryDelete)

	}

	// activity
	activityGroup := router.Group("activity")
	activityGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		activityGroup.GET("AllTypeList", activity.AllTypeList)
		activityGroup.GET("TypeList", activity.TypeList)
		activityGroup.POST("TypeEdit", activity.TypeEdit)
		activityGroup.POST("TypeDelete", activity.TypeDelete)

		activityGroup.GET("MyList", activity.MyList)
		activityGroup.GET("MyOneOrganizationList", activity.MyOneOrganizationList)
		activityGroup.POST("MyEdit", activity.MyEdit)
		activityGroup.GET("MyDetail", activity.MyDetail)
		activityGroup.POST("MyCheck", activity.MyCheck)
		activityGroup.POST("MyFinish", activity.MyFinish)
		activityGroup.POST("MyDelete", activity.MyDelete)

		activityGroup.GET("MyUserList", activity.MyUserList)
		activityGroup.GET("MyUserExitCheckList", activity.MyUserExitCheckList)
		activityGroup.POST("MyUserExitCheck", activity.MyUserExitCheck)
		activityGroup.POST("MyUserCheck", activity.MyUserCheck)
	}

	// organization
	organizationGroup := router.Group("organization")
	organizationGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		organizationGroup.GET("CategoryAllList", organization.CategoryAllList)

		organizationGroup.GET("AllList", organization.AllList)
		organizationGroup.GET("MyAllList", organization.MyAllList)
		organizationGroup.GET("MyList", organization.MyList)
		organizationGroup.GET("MyTree", organization.MyTree)
		organizationGroup.GET("Detail", organization.Detail)
		organizationGroup.POST("MyEdit", organization.MyEdit)
		organizationGroup.POST("MyDelete", organization.MyDelete)

		organizationGroup.GET("MyMapDetail", organization.MyMapDetail)
		organizationGroup.POST("MyMapEdit", organization.MyMapEdit)

		organizationGroup.GET("Map", organization.Map)

	}

	// help_request
	help_requestGroup := router.Group("help_request")
	help_requestGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		help_requestGroup.GET("MyList", help_request.MyList)
		help_requestGroup.POST("Read", help_request.Read)
	}

	// Index
	indexGroup := router.Group("index")
	indexGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		indexGroup.GET("Index", index.Index)
		indexGroup.GET("ExportXlsx", index.ExportXlsx)
	}

	// point_application
	point_applicationGroup := router.Group("point_application")
	point_applicationGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		point_applicationGroup.GET("List", point_application.List)
		point_applicationGroup.GET("MyList", point_application.MyList)
		point_applicationGroup.GET("Detail", point_application.Detail)
		point_applicationGroup.POST("Apply", point_application.Apply)
		point_applicationGroup.POST("Delete", point_application.Delete)
		point_applicationGroup.POST("Check", point_application.Check)
	}

	// material
	materialGroup := router.Group("material")
	materialGroup.Use(middleware.Record, middleware.Login, middleware.Permission)
	{
		materialGroup.GET("List", material.List)
	}

}
